package com.spring.rabbitmq.routing.direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.spring.rabbitmq.utils.RabbitMQUtils;
import lombok.SneakyThrows;

/**
 * @Author: lzx
 * @Data: 2021/04/29/9:22
 * @Description：
 */
public class Product {
    @SneakyThrows
    public static void main(String[] args) {
        Connection connection = RabbitMQUtils.getConnection();
        Channel channel = connection.createChannel();
        //参数1：交换机名称 参数2：交换机类型
        channel.exchangeDeclare("logs_direct", "direct");
        String key = "info";
        //发布消息
        channel.basicPublish("logs_direct", key, null, ("指定的routing key " + "["+key +"]"+ " 的消息").getBytes());
        //释放资源
        RabbitMQUtils.closeConnectionAndChannel(connection, channel);

    }
}
